<?php

/* 
生成验证码
 */

$image = imagecreatetruecolor(100, 20);
$c1 =  rand(100, 255);
$c2 =  rand(100, 255);
$c3 =  rand(100, 255);
$bc = imagecolorallocate($image, $c1, $c2, $c3);
imagefill($image, 0, 0, $bc);
$str="abcdefghijklmnopqrstuvwxyz1234567890";
for($i=1;$i<=4;$i++)
{   $q1=  rand(0, 100);
    $q2=  rand(0, 100);
    $q3=  rand(0, 100);
    $qc= imagecolorallocate($image, $q1, $q2, $q3);
    $char=  substr($str,rand(0,35),1);
    imagechar($image,5,10+$i*15,rand(1,10),$char,$qc);
    
}

for($i=1;$i<=15;$i++)
{
$c1 =  rand(100, 255);
$c2 =  rand(100, 255);
$c3 =  rand(100, 255);
$bc = imagecolorallocate($image, $c1, $c2, $c3);
imagechar($image,1,rand(0,99),rand(1,10),".",$qc);
}
header("Content-Type: image/png");
imagepng($image);

imagedestroy($image);
